vector=horzcat(vector,vari);          %concatenates the old vector and the new position
last=vector(end);
iteration=iteration+1;